package com.vois.jack.btmgr.devices.WLBleSBCDevice;

import com.vois.jack.btmgr.classicbase.BtRecorderInterface;
import com.vois.jack.btmgr.classicbase.BtSBCCodecRecorder;
import com.vois.jack.btmgr.devices.WLCommonBleDev.DefaultWLBleMediaDevice;
import com.vois.jack.btmgr.devices.WLCommonBleDev.WLBleCommand;

public class WLBleSbcDevice extends DefaultWLBleMediaDevice {
    BtRecorderInterface recorder;

    @Override
    public String getDeviceModel() {
        return "WLBleSBC Device";
    }

    @Override
    public void onScanStateChanged(int state) {

    }

    @Override
    public void onVerifying() {

    }

    @Override
    protected void onStreamDataProcess(byte[] data) {
        int flag1 = data[0] & 0xFF;
        int flag2 = data[1] & 0xFF;
        int len = data[2] & 0xFF;

        if (flag1 != 0xAA || flag2 != 0xBB) {
            return;
        }

        if (recorder != null) {
            recorder.putEncodedRecordData(data, 3, len);
        }
    }

    @Override
    public BtRecorderInterface getRecorder(int recoderType) {
        if (recoderType == SBC_RECORDER) {
            recorder = new BtSBCCodecRecorder();
            return recorder;
        }

        return null;
    }

    @Override
    protected int getRequestMaxMtu() {
        return 160;
    }

    @Override
    public int getDefaultRecorderType() {
        return SBC_RECORDER;
    }
}
